import React, { useState,useEffect } from 'react';
import { Modal, Button,Form,Input,Radio } from 'antd';
// import ModalForm from './modalForm';
const Edit = (props) => {
    const onFinish = (values) => {
      console.log(values);
    };
    const record = props.record;
    const [visible,setVisible] = useState(false);
    const [confirmLoading,setConfirmLoading] = useState(false);
    // const [modalText,setModalText] = useState('Content of the modal');

    const showModal = () => {
        setVisible(true);
    }
    const handleOk = () => {
        // setConfirmLoading(true);
        setTimeout(() => {
            setVisible(false);
            // setConfirmLoading(false);
        }, 2000);
    };
    const handleCancel = () => {
        console.log('Clicked cancel button');
        setVisible(false);
    }
    return (
    <>
      <Button type="text" onClick={showModal}>
       编辑
      </Button>
      <Modal
        title="编辑单位"
        visible={visible}
        onOk={handleOk}
        confirmLoading={confirmLoading}
        onCancel={handleCancel}
        footer={[
            // <Button key="back" onClick={handleCancel}>取消</Button>,
            
        ]}
      >
        <Form 
          onFinish={onFinish}
          initialValues={record}
        >
            <Form.Item
             label="单位ID"
             name="unitId"
            >
                <Input  />
            </Form.Item>
            <Form.Item
             label="单位名称"
             name="name"
            >
                <Input  />
            </Form.Item>
            <Form.Item
             label="单位地点"
             name="address"
            >
                <Input  />
            </Form.Item>
            <Form.Item>
              <Button htmlType="submit" type="primary"  onClick={handleOk}>提交</Button>
            </Form.Item>
        </Form>
      </Modal>
    </>
  )
}

export default Edit;
